package com.sk.bilibili.encoder;

import com.google.gson.Gson;
import com.sk.bilibili.dto.DanmuInfo;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

/**
 * @author 邵康
 * @date 2021/12/2 14:30
 * 负责所有json转码
 */
public class JsonEncoder implements Encoder.Text<Object>{

    @Override
    public String encode(Object object) throws EncodeException {
        return gson.toJson(object);
    }

    @Override
    public void init(EndpointConfig endpointConfig) {
        gson=new Gson();
    }

    private Gson gson;

    @Override
    public void destroy() {}

}
